<%@page contentType="text/html; charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="primus" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<primus:page title="添加广告">
    <jsp:attribute name="script">
        <script type="text/javascript">
            $("#beginDate").datetimepicker({
                showClear: true,
                format:"YYYY-MM-DD HH:mm:ss",
            });
            $("#endDate").datetimepicker({
                showClear: true,
                format:"YYYY-MM-DD HH:mm:ss",
            });
            saveFunction = function () {
                $("#ad-form").submit();
            }
        </script>
    </jsp:attribute>
    <jsp:body>
        <div class="breadcrumbs ace-save-state" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="welcome.do">
                        首页
                    </a>
                </li>
                <li>
                    运营管理
                </li>
                <li class="active">
                    添加广告
                </li>
            </ul>
            <a class="btn btn-xs btn-primary history-back">
                <i class="ace-icon fa fa-angle-left"></i>
                返回
            </a>
        </div>
        <div class="page-content">
            <h3 class="header smaller lighter blue">
                广告数据
            </h3>

            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->
                    <form id="contact-form" action="advertisement/ad/save.do" method="post" class="form-horizontal"
                          role="form">
                        <input type="hidden" name="id" id="id" value="${advertisement.id}"/>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="title"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> 标题 </font></font></label>
                            <div class="col-sm-9">
                                <input type="text" id="title" name="title" placeholder="标题" value="${advertisement.title}" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="second"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> 停留时间(秒数) </font></font></label>
                            <div class="col-sm-2">
                                <input type="number" step="1" min="1" id="second" name="second" value="${advertisement.second}" class="input-sm col-xs-10 col-sm-5" style="width: 6em">
                            </div>
                        </div>

                        <div class="space-4"></div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">
                                广告位
                            </label>
                            <div class="col-sm-2">
                                <select name="adPositionId" id="adPositionId" data-placeholder="选择广告位..." class="chosen-select form-control col-xs-12">
                                        <c:forEach items="${adPositionVos}" var="adposition">
                                            <c:choose>
                                                <c:when test="${advertisement.adPositionId eq adposition.id}">
                                                    <option value="${adposition.id}" selected>${adposition.name}</option>
                                                </c:when>
                                                <c:otherwise>
                                                    <option value="${adposition.id}" >${adposition.name}</option>
                                                </c:otherwise>
                                            </c:choose>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right">
                                    展示区域
                                </label>
                                <div class="col-sm-2">
                                        <%--<select name="adPositionId" id="adPositionId" data-placeholder="选择广告位..." class="chosen-select form-control col-xs-12">--%>
                                    <%--<c:forEach items="${adPositionVos}" var="adposition" varStatus="varStatus">--%>
                                    <%--<option value="${adposition.id}" >${adposition.name}</option>--%>
                                    <%--</c:forEach>--%>
                                    <%--</select>--%>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">展示区域</label>
                            <div class="col-sm-2">
                                <label>
                                    <c:choose>
                                        <c:when test="${advertisement.countryStatus}">
                                            <input name="countryStatus" type="checkbox" class="ace" checked>
                                        </c:when>
                                        <c:otherwise>
                                            <input name="countryStatus" type="checkbox" class="ace">
                                        </c:otherwise>
                                    </c:choose>
                                    <span class="lbl">全国</span>
                                </label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right">
                                广告类型
                            </label>
                            <div class="col-sm-2">
                                <select name="atype" id="atype" data-placeholder="选择广告类型" class="chosen-select form-control col-xs-12">
                                    <c:forEach items="${adTypeEnums}" var="adTypeEnum">
                                        <c:choose>
                                            <c:when test="${advertisement.atype.name() eq adTypeEnum.name()}">
                                                <option value="${adTypeEnum.name()}" selected>${adTypeEnum.desc}</option>
                                            </c:when>
                                            <c:otherwise>
                                                <option value="${adTypeEnum.name()}" >${adTypeEnum.desc}</option>
                                            </c:otherwise>
                                        </c:choose>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="url"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> 跳转链接 </font></font></label>
                            <div class="col-sm-9">
                                <input type="text" id="url" name="url" placeholder="跳转链接" value="${advertisement.url}" class="form-control">
                            </div>
                        </div>
                        <div class="space-4"></div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="beginDate"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> 起始日期 </font></font></label>
                            <div class="col-md-2">
                                <input id="beginDate" type="text" class="form-control" value="${advertisement.beginDate}" name="beginDate">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="endDate"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> 截止日期 </font></font></label>
                            <div class="col-md-2">
                                <input id="endDate" type="text" class="form-control" value="${advertisement.endDate}" name="endDate" size="10">
                            </div>
                        </div>

                        <%--
                        添加此处的上传图片 from提交不了
                        <div class="form-group" id="img">--%>
                            <%--<label class="col-sm-3 control-label no-padding-right" for="image"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> 图片 </font></font></label>--%>
                            <%--<div class="col-md-4">--%>
                                <%--<img id="image"  width="250px" height="250px" />--%>
                                <%--<div class="btn btn-info" id="logo_button">选择图片</div>--%>
                                <%--<form  enctype="multipart/form-data">--%>
                                    <%--<input type="file" id="logo_file"  name="file" />--%>
                                <%--</form>--%>
                                <%--<input name="sourcePath" type="hidden" id="logo_container" value="" />--%>
                            <%--</div>--%>
                        <%--</div>--%>

                        <div class="space-4"></div>
                        <div class="space-4"></div>
                        <div class="space-4"></div>
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button class="btn btn-info" type="submit" id="btn_save">
                                    <i class="ace-icon fa fa-check bigger-110"></i>
                                    保存
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="ace-icon fa fa-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </div>
                    </form>
                </div><!-- /.col -->
            </div>
        </div>
    </jsp:body>
</primus:page>
